home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
001-025
/
disk_005
/
parallel
/
parallel.c
< prev
Wrap
C/C++ Source or Header
|
1992-05-06
|
4KB
|
140 lines
/*
*
* DISCLAIMER:
*
* This program is provided as a service to the programmer
* community to demonstrate one or more features of the Amiga
* personal computer. These code samples may be freely used
* for commercial or noncommercial purposes.
*
* Commodore Electronics, Ltd ("Commodore") makes no
* warranties, either expressed or implied, with respect
* to the program described herein, its quality, performance,
* merchantability, or fitness for any particular purpose.
* This program is provided "as is" and the entire risk
* as to its quality and performance is with the user.
* Should the program prove defective following its
* purchase, the user (and not the creator of the program,
* Commodore, their distributors or their retailers)
* assumes the entire cost of all necessary damages. In
* no event will Commodore be liable for direct, indirect,
* incidental or consequential damages resulting from any
* defect in the program even if it has been advised of the
* possibility of such damages. Some laws do not allow
* the exclusion or limitation of implied warranties or
* liabilities for incidental or consequential damages,
* so the above limitation or exclusion may not apply.
*
*/
/* parallel.c .... parallel port test program. */
/* author: Tom Pohorsky, 12/1/85 */
#include "exec/types.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "exec/ports.h"
#include "exec/libraries.h"
#include "exec/devices.h"
#include "exec/io.h"
#include "devices/parallel.h"
struct IOExtPar IORpar;
struct MsgPort *port;
char buffer[64000];
extern struct MsgPort *CreatePort();
main()
{
int error;
int actual;
unsigned char pflags;
unsigned long pt0;
unsigned long pt1;
open:
/* OPEN the parallel.device */
if ((error = OpenDevice (PARALLELNAME, 0, &IORpar, 0)) != 0) {
printf ("bad news %ld on Open \n", error);
exit (error);
}
/* SET UP the message port in the I/O request */
port = CreatePort (PARALLELNAME,0);
IORpar.IOPar.io_Message.mn_ReplyPort = port;
/* SET PARAMS for the parallel.device */
pflags = PARF_EOFMODE;
pt0 = 0x51040303;
pt1 = 0x03030303;
if ((error = setparams (pflags,pt0,pt1)) != 0) {
printf ("bad news %ld on setup \n", error);
DeletePort();
exit (error);
}
actual = readPar (buffer,60000);
/* CLOSE the parallel.device */
CloseDevice (&IORpar);
DeletePort (port);
exit (0);
}
/* PARALLEL I/O functions */
setparams(pf,ta0,ta1)
unsigned char pf;
unsigned long ta0;
unsigned long ta1;
{
int error;
IORpar.io_ParFlags = pf;
IORpar.IOPar.io_Command = PDCMD_SETPARAMS;
IORpar.io_PTermArray.PTermArray0 = ta0;
IORpar.io_PTermArray.PTermArray1 = ta1;
if ((error = DoIO (&IORpar)) != 0) {
printf ("parallel.device setparams error %ld \n", error);
}
return (error);
}
readPar(data,length)
char *data;
ULONG length;
{
int error;
IORpar.IOPar.io_Data = data;
IORpar.IOPar.io_Length = length;
IORpar.IOPar.io_Command = CMD_READ;
if ((error = DoIO (&IORpar)) != 0) {
printf ("parallel.device read error %ld \n", error);
}
return (IORpar.IOPar.io_Actual);
}
writePar(data,length)
char *data;
int length;
{
int error;
IORpar.IOPar.io_Data = data;
IORpar.IOPar.io_Length = length;
IORpar.IOPar.io_Command = CMD_WRITE;
if ((error = DoIO (&IORpar)) != 0) {
printf ("parallel.device write error %ld \n", error);
}
return (error);
}